package com.extension.company.view.my.localorder.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.extension.company.admin.R;
import com.extension.company.model.entity.SameCityOrderAllBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * 同城 --未使用
 */
public class LocalCityOrderUnUseAdapter extends RecyclerView.Adapter<LocalCityOrderUnUseAdapter.ViewHolder> {


	private List<SameCityOrderAllBean> mValues;
	private OnListFragmentInteractionListener mListener;
	private Context context;

	public LocalCityOrderUnUseAdapter(List<SameCityOrderAllBean> items, Context context) {
		this.mValues = items;
		this.context = context;
	}

	@Override
	public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
		View view = LayoutInflater.from(parent.getContext())
				.inflate(R.layout.my_same_city_order_unuse_item, parent, false);
		return new ViewHolder(view);
	}

	@Override
	public void onBindViewHolder(final ViewHolder holder, int position) {


		holder.unUseBtnToUse.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				if (null != mListener) {

					mListener.localStoreUse();
				}
			}
		});
		holder.itemView.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				mListener.itemListener();
			}
		});
	}

	@Override
	public int getItemCount() {
		return 10;
	}

	public class ViewHolder extends RecyclerView.ViewHolder {

		@BindView(R.id.un_use_item_icon)
		ImageView unUseItemIcon;
		@BindView(R.id.un_use_item_store_name)
		TextView unUseItemStoreName;
		@BindView(R.id.un_use_item_product_title)
		TextView unUseItemProductTitle;
		@BindView(R.id.un_use_item_total_num)
		TextView unUseItemTotalNum;
		@BindView(R.id.un_use_item_total_price)
		TextView unUseItemTotalPrice;
		@BindView(R.id.item_left)
		Button itemLeft;
		@BindView(R.id.un_use_btn_to_use)
		Button unUseBtnToUse;

		public ViewHolder(View view) {
			super(view);
			ButterKnife.bind(this, view);

		}
	}

	public interface OnListFragmentInteractionListener {
		void localStoreUse(); // 本地店铺去使用

		void itemListener();
	}

	public void setOnListListener(OnListFragmentInteractionListener listener) {
		this.mListener = listener;
	}
}
